#lang racket (require rackunit) (require "extras.rkt") (require 2htdp/universe) (require 2htdp/image) (provide StatefulWorld<%> StatefulWidget<%> SimulatorState<%> Goofball<%> Robot<%>) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Interfaces for Problem Set 10 ;;; ;;; You are not allowed to modify any of these interfaces ;;; except for MyStatefulWorld<%> and MyWidget<%>. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define StatefulWorld<%> (interface () ;; -> Void ;; GIVEN: no arguments ;; EFFECT: updates this world to its state at the next tick after-tick ;; Integer Integer MouseEvent -> Void ;; GIVEN: a location and what kind of mouse event ;; EFFECT: updates this world to its state following the given mouse ;; event at the given location after-mouse-event ;; KeyEvent -> Void ;; GIVEN: a key event ;; EFFECT: updates this world to its state following the given key event after-key-event ;; -> Scene ;; GIVEN: no arguments ;; RETURNS: a scene that depicts the world to-scene )) (define StatefulWidget<%> (interface () ;; -> Void ;; GIVEN: no arguments ;; EFFECT: updates this widget to its state following a tick ;; while the world is not paused after-tick ;; -> Void ;; GIVEN: no arguments ;; EFFECT: updates this widget to its state following a tick ;; in which the world is paused after-tick-while-paused ;; Integer Integer -> Void ;; GIVEN: x and y coordinates for a location ;; RETURNS: updates this widget to its state following the specified ;; mouse event at the given location after-button-down after-button-up after-drag ;; KeyEvent -> Void ;; GIVEN: a key event ;; RETURNS: updates this widget to its state following the ;; given key event after-key-event ;; Scene -> Scene ;; GIVEN: a scene ;; RETURNS: a scene like the given one but with this widget painted on it add-to-scene )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; You are allowed to add methods to these two interfaces. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define MyStatefulWorld<%> (interface (StatefulWorld<%>) ;; you may list additional methods here )) (define MyStatefulWidget<%> (interface (StatefulWidget<%>) ;; you may list additional methods here )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; You are not allowed to modify these interfaces. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define SimulatorState<%> (interface (MyStatefulWorld<%>) ;; -> Integer ;; RETURN: the x and y coordinates of the launcher launcher-x launcher-y ;; -> ListOfGoofball<%> goofballs ;; -> ListOfRobot<%> robots )) (define StatefulWidgetWithLocationAndVelocity<%> (interface (MyStatefulWidget<%>) ;; -> Int ;; RETURNS: the x or y position of the center of this robot get-x get-y ;; -> Int ;; RETURNS: the vx or vy component of this robot's velocity get-vx get-vy )) (define Goofball<%> (interface (StatefulWidgetWithLocationAndVelocity<%>) ;; -> Boolean ;; RETURNS: true iff this goofball has the stealth of a Stealth Goofball stealthy? )) (define Robot<%> (interface (StatefulWidgetWithLocationAndVelocity<%>) ;; -> Boolean ;; RETURNS: true iff this robot has a SAGR's abilities smart? ))